package demoMod.stsconsole.map;

import demoMod.stsconsole.rooms.AbstractRoom;
import demoMod.stsconsole.rooms.EmptyRoom;

import java.util.ArrayList;
import java.util.List;

public class MapNode {
    public List<MapNode> prev = new ArrayList<>();
    public List<MapNode> next = new ArrayList<>();
    public AbstractRoom room = new EmptyRoom();

    public int x;
    public int y;

    private final List<MapEdge> edges = new ArrayList<>();

    public boolean hasEdges() {
        return !this.edges.isEmpty();
    }

    public void addEdge(MapEdge e) {
        boolean unique = true;

        for (MapEdge otherEdge : this.edges) {
            if (e.compareTo(otherEdge) == 0) {
                unique = false;
                break;
            }
        }

        if (unique) {
            this.edges.add(e);
        }
    }

    public String getRoomSymbol() {
        return room == null ? " " : room.getRoomSymbol();
    }

    public List<MapEdge> getEdges() {
        return this.edges;
    }


    public void delEdge(MapEdge edge) {
        this.edges.remove(edge);
    }
}
